﻿#pragma once
#include "EditEntry.h"

#include "EntryLabel.h"
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QPushButton>

class EditEntryUi {
    EditEntry *mWidget{nullptr};
public:
    EditEntryUi() = default;
    void SetupUI(EditEntry *widget);
    void RetranslateUI();
    QString TR(const QString &sourceText, const QString &disambiguation = "", int n = -1) {
        return mWidget->tr(sourceText.toStdString().c_str(), disambiguation.toStdString().c_str(), n);
    }
public:
    EntryLabel *labelName{nullptr};
    QWidget *areaName{nullptr};
    QHBoxLayout *layoutNameArea{nullptr};

    QPushButton *buttonExpend{nullptr};
    QPushButton *buttonCollapse{nullptr};
    QWidget *panelEdit{nullptr};
    QHBoxLayout *layoutEditPanel{nullptr};
    QWidget *areaEdit{nullptr};
    QHBoxLayout *layoutEditArea{nullptr};
    QWidget *areaOperate{nullptr};
    QHBoxLayout *layoutOperateArea{nullptr};
    QWidget *panelChild{nullptr};
    QVBoxLayout *layoutPanelChild{nullptr};
    QVBoxLayout *layoutRoot{nullptr};
};

inline void EditEntryUi::SetupUI(EditEntry *widget) {
    mWidget = widget;
    mWidget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);

    labelName = new EntryLabel;
    labelName->setAlignment(Qt::AlignVCenter | Qt::AlignLeft);
    labelName->setObjectName("EntryTitleLabel");

    layoutNameArea = new QHBoxLayout;
    layoutNameArea->setContentsMargins(0,0,0,0);
    layoutNameArea->setSpacing(0);
    layoutNameArea->addWidget(labelName);
    layoutNameArea->addStretch();

    areaName = new QWidget;
    areaName->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
    areaName->setLayout(layoutNameArea);
    areaName->setObjectName("EntryNameArea");

    layoutEditPanel = new QHBoxLayout;
    layoutEditPanel->setContentsMargins(0,0,0,0);
    layoutEditPanel->setSpacing(3);
    layoutEditPanel->addWidget(areaName);

    panelEdit = new QWidget;
    panelEdit->setLayout(layoutEditPanel);
    panelEdit->setObjectName("EntryEditPanel");

    layoutRoot = new QVBoxLayout;
    layoutRoot->setContentsMargins(0,0,0,0);
    layoutRoot->setSpacing(0);
    layoutRoot->addWidget(panelEdit);

    mWidget->setLayout(layoutRoot);
}

inline void EditEntryUi::RetranslateUI() {

}
